package org.summerframework.component.upload.util;




import org.summerframework.component.upload.type.UploadFileEnum;

import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.TimeZone;

/**
 * UploadFile
 *
 * @author YeKaiQiang
 * @date 2016/6/27
 */
public class UploadFile implements Serializable {

    private String name;

    private Integer type = 4;// 1:图片,2:音乐,3:视频,4:其他

    private String suffix;

    private String path;

    private Integer time = 0;

    private String thumb;

    private Map<UploadFileEnum, String> transferPath = new HashMap<>();

    public String getThumb() {
        return thumb;
    }

    public void setThumb(String thumb) {
        this.thumb = thumb;
    }

    public void putTransferPath(UploadFileEnum uploadFileEnum, String path) {
        transferPath.put(uploadFileEnum, path);
    }

    public String getTransfer(UploadFileEnum uploadFileEnum) {
        return transferPath.get(uploadFileEnum);
    }

    public String getSuffix() {
        return suffix;
    }

    public void setSuffix(String suffix) {
        this.suffix = suffix;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getTime() {
        return time;
    }

    /**
     * 获取时间
     *
     * @return
     */
    public String getTimeFormat(String pattern) {
        SimpleDateFormat sdf = new SimpleDateFormat(pattern);
        TimeZone.getAvailableIDs();
        TimeZone tz = TimeZone.getTimeZone("GMT+0:00");
        sdf.setTimeZone(tz);
        return sdf.format(new Date(time * 1000));
    }

    /**
     * 获取时间
     *
     * @return
     */
    public String getTimeFormat() {
        return getTimeFormat("HH:mm:ss");
    }

    public void setTime(Integer time) {
        this.time = time;
    }

    public Integer getType() {
        return type;
    }

    public void setType(Integer type) {
        this.type = type;
    }

    public String getPath() {
        return path;
    }

    public void setPath(String path) {
        this.path = path;
    }

    public Map<UploadFileEnum, String> getTransferPath() {
        return transferPath;
    }

    public void setTransferPath(Map<UploadFileEnum, String> transferPath) {
        this.transferPath = transferPath;
    }
}
